import cv2
import time

def getOutline(path):
    img = cv2.imread(path)
    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    ret, binary = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
    contours, hierarchy = cv2.findContours(binary, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

    timestamp = time.time()
    area = 0
    x, y, w, h = 0, 0, 0, 0
    for i in range(0, len(contours)):
        ax, ay, aw, ah = cv2.boundingRect(contours[i])
        temp_area = aw * ah
        if temp_area > area:
            area = temp_area
            x, y, w, h = ax, ay, aw, ah

    xmin = x
    xmax = x + w
    ymin = y
    ymax = y + h

    cv2.rectangle(img, (x, y), (x+w, y+h), (153, 153, 0), 5)
    cv2.imwrite("./temp/"+str(timestamp)+".jpg", img)
    cv2.imshow("img", img)
    cv2.waitKey(0)
    return xmin, xmax, ymin, ymax
